package cn.yunyichina.provider.base.service.impl;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import cn.yunyichina.provider.base.dao.PlatformDeptRelationDao;
import cn.yunyichina.provider.base.entity.PlatformDeptRelation;
import cn.yunyichina.provider.base.utils.StringUtils;
import cn.yunyichina.provider.iface.entity.common.Response;
import cn.yunyichina.utils.convert.JsonUtils;
/**
 * 
 * @projectName:yyt-provider-base
 * @author:yangfan
 * @description:平台科室与医院关系对照操作
 * @date:2016年11月10日
 * @className:PlatformdeptrelationServiceImpl
 * @pakeage:cn.yunyichina.provider.base.service.impl
 */
public class PlatformdeptrelationServiceImpl {
	@Autowired
	private PlatformDeptRelationDao platformDeptRelationDao;
	
	private static final Logger logger = LoggerFactory.getLogger(PlatformdeptrelationServiceImpl.class);
	/**
	 * 
	 * @methodName:updatePlatformdeptrelation
	 * @description:修改医院科室对照关系表
	 * @author:yangfan
	 * @date:2016年11月10日
	 * @param data
	 * @return:Response
	 */
	public Response updatePlatformdeptrelation(String data){
		Response response = new Response();
		PlatformDeptRelation platformDeptRelation = new PlatformDeptRelation();
		Map<String, String> map = JsonUtils.parseObject(data, Map.class);
		if(StringUtils.isBlank(map.get("id"))){
			response.setResultCodeAndMessage("1101", "关系编号不能为空");
			return response;
		}
		if(StringUtils.isBlank(map.get("platform_deptid"))){
			response.setResultCodeAndMessage("1101", "平台科室编号不能为空");
			return response;
		}
		platformDeptRelation.setPlatformDeptId(map.get("platform_deptId"));
		platformDeptRelation.setHospitalDeptId(map.get(""));
		platformDeptRelation.setId(map.get("id"));
		
		try {
			this.platformDeptRelationDao.update(platformDeptRelation);
			response.setResultCodeAndMessage("0", "修改成功");			
		} catch (Exception e) {
			logger.error("修改平台医院科室关系失败",e.toString());
			response.setResultCodeAndMessage("1999", "修改平台医院科室关系发生异常");
		}
		
		return response;
	}
}
